<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
      {{num}}
      {{ num2 }}
      <button @click="changeNum2">修改计算属性</button>
  </div>
  <script src="./vue.js"></script>
  <script>
    const vm = new Vue({
      el: "#app",
      data:{
        num: 20
      },
      methods:{
        changeNum2(){
          // 直接修改计算属性
          this.num2 = 100
        }
      },
      computed:{
        num2(){
          return this.num*2
        } 
       /*  num2:{
          get(){
            console.log("获取了")
            return this.num*2
          },
          set(val){
            console.log('设置值了'+val)
            this.num = val/2
          }
        } */
      }
    })
  </script>
</body>
</html>
